import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { IPage, ISeat } from "./types";

/* 查询座位列表 */
export function getPageSeatAPI(
  queryParams?: IPage
): AxiosPromise<PageResult<ISeat[]>> {
  return request({
    url: "/seat/page",
    method: "get",
    params: queryParams,
  });
}
/* 根据id查询座位对象 */
export function getFormSeatAPI(id: number): AxiosPromise<ISeat> {
  return request({
    url: `/seat/${id}/form`,
    method: "get",
  });
}

/**
 * 添加座位
 *
 * @param data
 */
export function addSeatAPI(data: any) {
  return request({
    url: "/seat",
    method: "post",
    data: data,
  });
}

/**
 * 修改座位
 *
 * @param id
 * @param data
 */
export function updateSeatAPI(id: number, data: ISeat) {
  return request({
    url: "/seat/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 删除座位
 *
 * @param ids
 */
export function deleteSeatAPI(ids: number) {
  return request({
    url: "/seat/" + ids,
    method: "delete",
  });
}

/* 实验室座位预约 */
export function getSeatListByLabIdAPI(data: any): AxiosPromise<ISeat[]> {
  return request({
    url: `/seat/status`,
    method: "Post",
    data: data,
  });
}
